﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RenAi.Medical.BLL;
using RenAi.Medical.Model;


namespace RenAi.Medical.Admin
{

    
    public partial class AddDorcor : System.Web.UI.Page
    {

        DocBll bll = new DocBll();
        HBKeShiBll hbll = new HBKeShiBll();

        public void LoadHBKeShi()   //加载所有科室信息，并绑定到下拉列表框中 
        {
            this.DropDownList1.DataSource = hbll.GetHBKeShiAll();
            this.DropDownList1.DataValueField = "HBKeShi_Id";
            this.DropDownList1.DataTextField = "HBKeShi_Name";
            this.DropDownList1.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadHBKeShi();
            }

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Doctor d = new Doctor();
            d.Doctor_Name = this.tetname.Text;
           
            d.IFZhuanJia = int.Parse(this.rbtnyi.Checked ? "1" : "0");
            d.HBKeShi_Id = int.Parse(this.DropDownList1.SelectedValue);
            d.Doctor_Img = this.txtimg.Text;
            d.Experience = this.txtjing.Text;
            d.Adept = this.txtzhuan.Text;
            d.Num = int.Parse(this.txtsum.Text);
            if(bll.AddDoctor(d)>0)
            {
                Response.Write("<script>alert('添加成功!');</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!');</script>");
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("yisheng.aspx");
        }
    }
}